package com.example.demo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonInclude(Include.NON_NULL)
public class Result {
	private int code;
	private String msg;
	private Object data;
	
	public Result (int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public static Result ok() {
		return new Result(0, "ok");
	}
	
	public static Result ok(Object data) {
		Result v = Result.ok();
		v.data = data;
		return v;
	}
	
	public static Result error(int code, String msg) {
		return new Result(code, "ok");
	}
}
